package com.sh.controller.admin;

import com.sh.common.BaseResult;
import com.sh.service.user.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/admin/user")
public class AdminUserController {
    @Autowired
    private IUserService userService;

    /**
     * 分页查询用户
     */
    @GetMapping("/list")
    public BaseResult listUser(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        return BaseResult.success(userService.listUsers(pageNum, pageSize));
    }

    /**
     * 查询当前用户的用户信息
     */
    @GetMapping("/get")
    public BaseResult get() {
        return BaseResult.success(userService.getUserInfo());
    }

    /**
     * 查询指定用户的用户信息
     */
    @GetMapping("/get/{userId}")
    public BaseResult getByUserId(@PathVariable String userId) {
        return BaseResult.success(userService.getUserInfoById(userId));
    }


}
